import $ from 'jquery'
import createReactUnit from "./unit.js";
import createElement from './element'
import Component from './component'

let React = {
  render,
  createElement,
  Component,
  nextRootIndex: 0
}
function render(ele, container) {
  // 工厂函数处理不同的类型，创建并返回对应的react元素实例
  let createReactUnitInstance = createReactUnit(ele)
  let markUp = createReactUnitInstance.getMarkUp(React.nextRootIndex)
  // console.log("markUp===", markUp);
  // let markUp = `<span data-reactid=${React.nextRootIndex}>${ele}</span>`;
  $(container).html(markUp)
  // 触发 DOM挂载完成的方法
  $(document).trigger('mounted') // 所有组件都ok了
}

export default React;